package com.qg.lizhanqi.videosquare.uitlhelp;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

import com.yolanda.nohttp.rest.Request;

import org.json.JSONObject;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * Created by lizhanqi on 2016-8-17-0017.
 */
public class MyUtils {
    private String message;
    private Request<JSONObject> jsonObjectRequest;
    private static WindowManager wm;
    private static DisplayMetrics displayMetrics;
    /*手机号判断*/
    public static boolean isuserPhoneNumber(String number) {
        String REGEX_MOBILE_SIMPLE = "^[1]\\d{10}$";
        //把正则表达式的规则编译成模板
        Pattern pattern = Pattern.compile(REGEX_MOBILE_SIMPLE);
        Matcher matcher = pattern.matcher(number);
        return matcher.find();
    }
    public static int GetScreenWidth(Context context){
        if (wm == null) {
            displayMetrics = new DisplayMetrics();
            wm = (WindowManager) context.getSystemService(context.WINDOW_SERVICE);
        }
        wm.getDefaultDisplay().getMetrics(displayMetrics);
        return displayMetrics.widthPixels;
    }
    public static  int GetScreenHeight(Context context){
        if (wm == null) {
            displayMetrics = new DisplayMetrics();
            wm = (WindowManager) context.getSystemService(context.WINDOW_SERVICE);
        }
        wm.getDefaultDisplay().getMetrics(displayMetrics);
        return displayMetrics.heightPixels;
    }

}
